#ifndef ENCFILE_H
#define ENCFILE_H

#include <fstream>
#include <iostream>
#include <rsa.h>
#include <String>
#include <QString>
#include <QDebug>
#include <..\include\md5.h>
#include "sqlconn.h"
#include "filters.h"
#include "hex.h"
#include "randpool.h"

#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
#define MAX_BUFFER_SIZE 134217728 //128M

using namespace  std;
using namespace CryptoPP;

#pragma comment(lib, "cryptlib.lib")

class Encfile
{
public:
    Encfile(string path, int uid, QString encdir,  QString usrName, QString fformat);
    Encfile(int  , QString );
    void copy();
    void del();
    void create();

public:
    string strPub;
private:
    string strPriv;
    string originPath;
    int id;
    int usrId;
    QString dir;
    QString filename;
    QString encFilename;
    long size;
    long startptr;
    long endptr;
    QString format;
    QString usrname;
    sqlConn *con;
    QString relativePath;
    static RandomPool m_sRandPool;

private:
    string RSAEncryptString(string );
    string RSADecryptString(string );
    void generateRSAKeys();
    void queryInfo();
    void findDataSpace(long );
    static RandomPool & RNG(void);
};

#endif // ENCFILE_H
